//
//  WSAddBluetoothView.m
//  FamilyLinkPro
//
//  Created by 江鹏 on 2023/9/13.
//  Copyright © 2023 SiterWell.Co.,Ltd. All rights reserved.
//

#import "WSAddDeviceBluetoothView.h"

@implementation WSAddDeviceBluetoothView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

// MARK: 添加子控件
- (void)setupSubviews {
    UILabel *addDeviceLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    addDeviceLabel.font = fontBold(21);
    addDeviceLabel.text = @"添加设备";
    addDeviceLabel.textColor = UIColorFromRGB_0x(0x333333);
    [self addSubview:addDeviceLabel];
    [addDeviceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).offset(kTopHeight + 50);
    }];
    
    UILabel *addDeviceMetionLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    addDeviceMetionLabel.font = fontBold(14);
    addDeviceMetionLabel.text = @"请将手机尽量靠近要添加的设备";
    addDeviceMetionLabel.numberOfLines = 0;
    addDeviceMetionLabel.textAlignment = NSTextAlignmentCenter;
    addDeviceMetionLabel.textColor = UIColorFromRGB_0x(0x666666);
    [self addSubview:addDeviceMetionLabel];
    [addDeviceMetionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(addDeviceLabel.mas_bottom).offset(20);
        make.left.mas_equalTo(self).offset(39);
        make.right.mas_equalTo(self).offset(-39);
    }];
    
    [self addSubview:self.findDeviceView];
    [self.findDeviceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(addDeviceMetionLabel.mas_bottom).offset(10);
        make.left.right.mas_equalTo(self);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-[WSDeviceHelper safeAreaInsetsBottom]);
    }];
    
    
    [self addSubview:self.searchDeviceView];
    [self.searchDeviceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(addDeviceMetionLabel.mas_bottom).offset(10);
        make.left.right.mas_equalTo(self);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-[WSDeviceHelper safeAreaInsetsBottom]);
    }];
    self.findDeviceView.hidden = YES;
    self.searchDeviceView.hidden = YES;
}

// MARK: 根据搜索界面类型现实不同的页面

- (void)layoutSubviewsWithAddDeviceDisplyType:(AddDeviceDisplyType)addDeviceDisplyType {
    switch (addDeviceDisplyType) {
        case AddDeviceDisplySearchType:
            self.searchDeviceView.hidden = NO;
            self.findDeviceView.hidden = YES;
            break;
            
        case AddDeviceDisplyFoundType:
            self.findDeviceView.hidden = NO;
            self.searchDeviceView.hidden = YES;
            break;
            
        default:
            break;
    }
}


// MARK: lazy

- (WSFindDeviceView *)findDeviceView {
    if (!_findDeviceView) {
        _findDeviceView = [[WSFindDeviceView alloc] initWithFrame:CGRectZero];
    }
    return _findDeviceView;
}


- (WSSearchDeviceView *)searchDeviceView {
    if (!_searchDeviceView) {
        _searchDeviceView = [[WSSearchDeviceView alloc] initWithFrame:CGRectZero];
    }
    return _searchDeviceView;
}



@end
